<?php

	class actionAuditModel extends Model{
		public function actionAuditAction(){
			$strip = 5;
			$page = isset($_GET['page'])?$_GET['page']:0;
			$start = $page*$strip;

			$sql = "select a.*,u.username,t.type from activity a LEFT JOIN `user` u on a.uid = u.id LEFT JOIN `activitytype` t on a.activityType = t.id  where a.status = 0 limit $start,$strip";
	        $data = $this->link->selectDB($sql);
			
	        echo json_encode($data);
		}

		public function SearchAction(){
			$strip = 5;
			$page = isset($_GET['page'])?$_GET['page']:0;
			$start = $page*$strip;
			$searchInfo = isset($_GET['searchInfo'])?$_GET['searchInfo']:'';
			$sql = "select a.*,u.username,t.type from activity a LEFT JOIN `user` u on a.uid = u.id LEFT JOIN `activitytype` t on a.activityType = t.id where a.activityName like '%$searchInfo%' and a.status = 0 limit $start,$strip";
			$data = $this->link->selectDB($sql);
			echo json_encode($data);
		}

		public function PagerAction(){
			$strip = 5;
			$sql = "select count(id) from activity where status = 0 ";
			$data = $this->link->selectDB($sql);
			$row = ceil($data[0]['count(id)']/$strip);
			echo json_encode($row);
		}

		public function PagersearchAction(){
			$strip = 5;
			$page = isset($_GET['page'])?$_GET['page']:0;
			$start = $page*$strip;
			$searchInfo = isset($_GET['searchInfo'])?$_GET['searchInfo']:'';
			$sql = "select count(id) from activity where  activityName like '%$searchInfo%' and status = 0 ";
			$data = $this->link->selectDB($sql);
			$row = ceil($data[0]['count(id)']/$strip);
			echo json_encode($row);
        }
        
        public function actionPassAction(){
            $id = isset($_GET['id'])?$_GET['id']:0;
            $sql = "update activity set status = 1 where id = $id";
            $data = $this->link->query($sql);
			echo json_encode($data);
        }

        public function actionBanAction(){
            $id = isset($_GET['id'])?$_GET['id']:0;
            $sql = "update activity set status = 2 where id = $id";
            $data = $this->link->query($sql);
			echo json_encode($data);
		}
		
		

	}